﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using DiscoveryLogic.Common.Utilities;

namespace DiscoveryLogic.Analytics.DataObjects.Measures
{
    public class VerticeMeasure
    {
        private EntityType _EntityType;
        /// <summary></summary>
        public EntityType EntityType
        {
            get
            {
                return this._EntityType;
            }
            set
            {
                this._EntityType = value;
            }
        }

        private string _ID;
        /// <summary></summary>
        public string ID
        {
            get
            {
                return this._ID;
            }
            set
            {
                this._ID = value;
            }
        }

        private string _Name;
        /// <summary></summary>
        public string Name
        {
            get
            {
                return this._Name;
            }
            set
            {
                this._Name = value;
            }
        }

        private int _Degree;
        /// <summary></summary>
        public int Degree
        {
            get
            {
                return this._Degree;
            }
            set
            {
                this._Degree = value;
            }
        }

        private int _InDegree;
        /// <summary></summary>
        public int InDegree
        {
            get
            {
                return this._InDegree;
            }
            set
            {
                this._InDegree = value;
            }
        }

        private int _OutDegree;
        /// <summary></summary>
        public int OutDegree
        {
            get
            {
                return this._OutDegree;
            }
            set
            {
                this._OutDegree = value;
            }
        }

        private double _CloseCentrality;
        /// <summary></summary>
        public double CloseCentrality
        {
            get
            {
                return this._CloseCentrality;
            }
            set
            {
                this._CloseCentrality = value;
            }
        }

        private double _BetweenCentrality;
        /// <summary></summary>
        public double BetweenCentrality
        {
            get
            {
                return this._BetweenCentrality;
            }
            set
            {
                this._BetweenCentrality = value;
            }
        }

        private int _Flow;
        /// <summary></summary>
        public int Flow
        {
            get
            {
                return this._Flow;
            }
            set
            {
                this._Flow = value;
            }
        }

        public static DataTable ToDataTable(List<VerticeMeasure> vMeasures)
        {
            DataTable dtVMeasure=new DataTable();
            dtVMeasure.Columns.Add("EntityType", typeof(EntityType));
            dtVMeasure.Columns.Add("ID", typeof (string));
            dtVMeasure.Columns.Add("Name", typeof (string));
            dtVMeasure.Columns.Add("Degree", typeof (int));
            dtVMeasure.Columns.Add("InDegree", typeof (int));
            dtVMeasure.Columns.Add("OutDegree", typeof (int));
            dtVMeasure.Columns.Add("BetweenCentrality", typeof (double));
            dtVMeasure.Columns.Add("CloseCentrality", typeof (double));
            dtVMeasure.Columns.Add("Flow", typeof (int));

            foreach(VerticeMeasure vMeasure in vMeasures)
            {
                DataRow dr = dtVMeasure.NewRow();
                dr["EntityType"] = vMeasure.EntityType;
                dr["ID"] = vMeasure.ID;
                dr["Name"] = vMeasure.Name;
                dr["Degree"] = vMeasure.Degree;
                dr["InDegree"] = vMeasure.InDegree;
                dr["OutDegree"] = vMeasure.OutDegree;
                dr["BetweenCentrality"] = Math.Round(vMeasure.BetweenCentrality, 2);
                dr["CloseCentrality"] = Math.Round(vMeasure.CloseCentrality, 2);
                dr["Flow"] = vMeasure.Flow;
                dtVMeasure.Rows.Add(dr);
            }
            return dtVMeasure;
        }
    }
}
